import  axios from 'axios';

function httpRequest(url, data ={}, methods = 'get'){
    return new Promise((resolve,reject)=>{
        const option={
            url,
            methods
        }
        if(methods.toLowerCase==='get'){
            option.params=data
        }else{
            option.data=data
        }

        axios(option).then(res=>{
            resolve(res);
        })
        .catch(err=>{
            reject();
            console.log(err);
        })
    })
}

export default httpRequest;